import React, {Component} from 'react';
import {Table, Input, Button, message} from 'antd';
import "./UpperPartOfTheForm.css";
import moment from 'moment';
import XLSX from 'xlsx';

class UpperPartOfTheForm extends Component {

    constructor(props) {
        super(props);
        this.state = {
            Time: [],//第一列的时间变化自动控制
            Data: [],//原始填写的数据
            passRate: [],//合格率
            average: [],//平均
        }
    }


    /**初始化**/
    componentDidMount() {
        //绑定ref
        this.props.onRef(this);
    }

    /**
     * 第一列的时间变化
     */
    componentWillMount() {
        const allTime = [
            ['0:00', '1:00', '2:00', '3:00', '4:00', '5:00', '6:00', '7:00'],
            ['8:00', '9:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00'],
            ['16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00']
        ];
        this.setState({
            Time: [...allTime[this.props.timeChose]],
            Data: this.props.upperData,
        })
    }

    /**更新props**/
    componentWillReceiveProps(nextProps) {
        const allTime = [
            ['0:00', '1:00', '2:00', '3:00', '4:00', '5:00', '6:00', '7:00'],
            ['8:00', '9:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00'],
            ['16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00']
        ];
        this.setState({
            Time: [...allTime[nextProps.timeChose]],
            Data: nextProps.upperData,
        });
        this.updataData_Initial(nextProps.standard);
    }

    //暂存函数
    postToHome(i) {//i是行数
        const xiaoshi = i + this.props.timeChose * 8;
        const a = this.state.Data[xiaoshi]['shuju'];
        const shuju = a.join(',');
        const jsondata = {
            "data": [
                {
                    "riqi": this.props.riqi,
                    "xiaoshi": xiaoshi,
                    "leixing": "CMS",
                    "zhonglei": 1,
                    "shuju": shuju,
                    "name": window.localStorage.name,
                }
            ]
        };
        fetch("/api/HuaYS/save", {
            method: 'POST',
            body: JSON.stringify(jsondata), // data can be `string` or {object}!
            headers: {
                'Content-Type': 'application/json',
                'authorization': window.localStorage.authorization,
            }
        })
            .then(res => res.json())
            .then(data => {
                if (data['code'] === 0) {
                    message.info('暂存成功');
                    const Data = this.state.Data;
                    Data[xiaoshi]['name'] = window.localStorage.name;
                    this.setState({
                        Data: Data
                    })
                }
            })
            .catch(error => console.error('Error:', error))
            .then(response => console.log('Success:', response));
    }

    //提交函数
    postAllToHome() {
        const timeChoose = this.props.timeChose * 8;
        for (let i = timeChoose; i < timeChoose + 8; i++) {
            const a = this.state.Data[i]['shuju'];
            const shuju = a.join(',');
            const jsondata = {
                "data": [
                    {
                        "riqi": this.props.riqi,
                        "xiaoshi": i,
                        "leixing": "CMS",
                        "zhonglei": 1,
                        "shuju": shuju,
                        "name": window.localStorage.name,
                    }
                ]
            };
            fetch("/api/HuaYS/save", {
                method: 'POST',
                body: JSON.stringify(jsondata), // data can be `string` or {object}!
                headers: {
                    'Content-Type': 'application/json',
                    'authorization': window.localStorage.authorization,
                }
            })
                .then(res => res.json())
                .then(data => {
                    if (data['code'] === 0) {
                        message.info('提交' + i + '点钟数据成功');
                        const Data = this.state.Data;
                        Data[i]['name'] = window.localStorage.name;
                        this.setState({
                            Data: Data
                        })
                    }
                    else if (data['code'] === 1) {
                        message.error('提交' + i + '点钟数据失败');
                    }
                })
                .catch(error => console.error('Error:', error))
        }
    }

    updataData_Initial(standard) {
        let temp1 = 0;//计算均值和合格率的临时数据
        let temp2 = 0;
        let temp3 = 0;
        let str = '';//计算合格比率的临时数据
        let inputCount0 = [], inputCount8 = [], inputCount16 = [];//各班次输入的总数
        let passCount0 = [], passCount8 = [], passCount16 = [];//各班次的合格数
        let passRate0 = [], passRate8 = [], passRate16 = [];//各班次的合格率
        let ratio0 = [], ratio8 = [], ratio16 = [];//各班次的合格比率
        //计算合格率部分
        for (let i = 0; i < 15; i++) {//i是列
            inputCount0[i] = 0;//0点班输入的总数
            passCount0[i] = 0;//0点班合格数
            inputCount8[i] = 0;//8点班输入的总数
            passCount8[i] = 0;//8点班合格数
            inputCount16[i] = 0;//16点班输入的总数
            passCount16[i] = 0;//16点班合格数
            for (let j = 0; j <= 7; j++) {//j是行
                if (!isNaN(this.state.Data[j]['shuju'][i]) && (this.state.Data[j]['shuju'][i] != null)) {
                    inputCount0[i]++;
                    if (this.state.Data[j]['shuju'][i] <= standard[i]) {
                        passCount0[i]++;
                    }
                }
                if (inputCount0[i] === 0) {
                    str = null;
                    temp1 = null;
                }
                else {
                    str = passCount0[i] + '\/' + inputCount0[i];
                    if (isNaN(temp1 = passCount0[i] / inputCount0[i])) {
                        temp1 = null;
                    }
                    else {
                        temp1 = Number(temp1 * 100).toFixed(1) + '%';
                    }
                }
                ratio0[i] = str;
                passRate0[i] = temp1;
            }
            for (let j = 8; j <= 15; j++) {//j是行
                if (!isNaN(this.state.Data[j]['shuju'][i]) && (this.state.Data[j]['shuju'][i] != null)) {
                    inputCount8[i]++;
                    if (this.state.Data[j]['shuju'][i] <= standard[i]) {
                        passCount8[i]++;
                    }
                }
                if (inputCount8[i] === 0) {
                    str = null;
                    temp1 = null;
                }
                else {
                    str = passCount8[i] + '\/' + inputCount8[i];
                    if (isNaN(temp1 = passCount8[i] / inputCount8[i])) {
                        temp1 = null;
                    }
                    else {
                        temp1 = Number(temp1 * 100).toFixed(1) + '%';
                    }
                }
                ratio8[i] = str;
                passRate8[i] = temp1;
            }
            for (let j = 16; j <= 23; j++) {//j是行
                if (!isNaN(this.state.Data[j]['shuju'][i]) && (this.state.Data[j]['shuju'][i] != null)) {
                    inputCount16[i]++;
                    if (this.state.Data[j]['shuju'][i] <= standard[i]) {
                        passCount16[i]++;
                    }
                }
                if (inputCount16[i] === 0) {
                    str = null;
                    temp1 = null;
                }
                else {
                    str = passCount16[i] + '\/' + inputCount16[i];
                    if (isNaN(temp1 = passCount16[i] / inputCount16[i])) {
                        temp1 = null;
                    }
                    else {
                        temp1 = Number(temp1 * 100).toFixed(1) + '%';
                    }
                }
                ratio16[i] = str;
                passRate16[i] = temp1;
            }
            let ratio = ratio0.concat(ratio8);
            ratio = ratio.concat(ratio16);
            let passRate = passRate0.concat(passRate8);
            passRate = passRate.concat(passRate16);
            this.setState({
                ratio: ratio,
                passRate: passRate,
            })
        }
        //计算均值的部分
        let average0 = [], average8 = [], average16 = [];//各班次的合格率
        for (let i = 0; i < 15; i++) {
            temp1 = 0;
            temp2 = 0;
            temp3 = 0;
            if (inputCount0[i] === 0) {
                temp1 = null;
            }
            else {
                for (let j = 0; j < 8; j++) {
                    if (!isNaN(this.state.Data[j]['shuju'][i])) {
                        temp1 += this.state.Data[j]['shuju'][i];
                    }
                }
                if (isNaN(temp1 = temp1 / inputCount0[i])) {
                    temp1 = 0;
                }
                temp1 = temp1.toFixed(3);
            }
            average0[i] = temp1;
            if (inputCount8[i] === 0) {
                temp2 = null;
            }
            else {
                for (let j = 8; j < 16; j++) {
                    if (!isNaN(this.state.Data[j]['shuju'][i])) {
                        temp2 += this.state.Data[j]['shuju'][i];
                    }
                }
                if (isNaN(temp2 = temp2 / inputCount8[i])) {
                    temp2 = 0;
                }
                temp2 = temp2.toFixed(3);
            }
            average8[i] = temp2;
            if (inputCount16[i] === 0) {
                temp3 = null;
            }
            else {
                for (let j = 16; j < 24; j++) {
                    if (!isNaN(this.state.Data[j]['shuju'][i])) {
                        temp3 += this.state.Data[j]['shuju'][i];
                    }
                }
                if (isNaN(temp3 = temp3 / inputCount16[i])) {
                    temp3 = 0;
                }
                temp3 = temp3.toFixed(3);
            }
            average16[i] = temp3;
        }
        let average = average0.concat(average8);
        average = average.concat(average16);
        this.setState({
            average: average
        });
    }

    /***
     * 进行底部的合格率、平均数的计算更新以及是否正常的判断
     **/
    updataData(standard) {
        let temp1 = 0;
        let inputCount = [];
        let passCount = [];
        let xiaoshi = this.props.timeChose * 8;//都加上选择的时间
        const Data = this.state.Data;
        const passRate = this.state.passRate;
        const average = this.state.average;
        for (let i = 0; i < 15; i++) {//i是列
            inputCount[i] = 0;//输入的总数
            passCount[i] = 0;//合格数
            for (let j = xiaoshi; j < xiaoshi + 8; j++) {//j是行
                // Data[j]['shuju'][i] = parseFloat(Data[j]['shuju'][i]);
                if (!isNaN(Data[j]['shuju'][i]) && (Data[j]['shuju'][i] != null)) {
                    inputCount[i]++;
                    if (Data[j]['shuju'][i] <= standard[i]) {
                        passCount[i]++;
                    }
                }
                if (inputCount[i] === 0) {
                    temp1 = null;
                }
                else {
                    if (isNaN(temp1 = passCount[i] / inputCount[i])) {
                        temp1 = null;
                    }
                    else {
                        temp1 = Number(temp1 * 100).toFixed(1) + '%';
                    }
                }
                passRate[i + this.props.timeChose * 15] = temp1;
            }
        }
        //计算均值的部分
        for (let i = 0; i < 15; i++) {
            temp1 = 0;
            if (inputCount[i] === 0) {
                temp1 = null;
            }
            else {
                for (let j = xiaoshi; j < xiaoshi + 8; j++) {
                    if (!isNaN(Data[j]['shuju'][i])) {
                        temp1 += Data[j]['shuju'][i];
                    }
                }
                if (isNaN(temp1 = temp1 / inputCount[i])) {
                    temp1 = 0;
                }
                temp1 = temp1.toFixed(3);
            }
            average[i + this.props.timeChose * 15] = temp1;
        }
        this.setState({
            passRate: passRate,//合格率
            average: average
        })
    }

    /**
     * 表格输入数据变化的监听，同时所有的数据更新
     **/
        //event输入框的值
    onInputNumberChange2 = (event, indexH, indexL) => {
        let NewData = this.state.Data;
        let xiaoshi = indexH + this.props.timeChose * 8;
        const rep = /^(\-)*(\d+)\.(\d{2}).*$/;
        event = event.replace(rep, '$1$2.$3');
        NewData[xiaoshi]["shuju"][indexL] = event;
        this.setState({
            Data: NewData
        });
    };
    onInputNumberChange3 = (event, indexH, indexL) => {
        let NewData = this.state.Data;
        let xiaoshi = indexH + this.props.timeChose * 8;
        const rep = /^(\-)*(\d+)\.(\d{3}).*$/;
        event = event.replace(rep, '$1$2.$3');
        NewData[xiaoshi]["shuju"][indexL] = event;
        this.setState({
            Data: NewData
        });
    };
    //  控制输入框样式
    changeStyle = (value) => {
        if (value) {
            if (isNaN(value) || value > 100) {
                return {
                    borderColor: 'red',
                    color: 'red',
                }
            }
        }
    }
    onInputStringChange = (event, indexH, indexL) => {
        let NewData = this.state.Data;
        let xiaoshi = indexH + this.props.timeChose * 8;
        NewData[xiaoshi]["shuju"][indexL] = event.target.value;
        this.setState({
            Data: NewData
        });
    };


    //导出数据
    ExportExcel = () => {
        const day=(['天','一','二','三','四','五','六']);
        const data = [
            [
                moment().format('YYYY年MM月DD日'),
                "星期"+day[moment().format('d')],
                '班次:'+this.props.timeChose*8+'点班',
                null, null, null,
                null, null, null,
                null, null, null,
                null, null, null,
                null, null, null,
            ],
            [
                "时间",
                "附着水",
                "不溶物",
                "LL/%",
                "SiO2/%",
                "Al2O3/%",
                "Fe2O3/%",
                "CaO/%",
                "MgO/%",
                "MnO/%",
                "TO/%",
                "SO3/%",
                "合计",
                "KH/%",
                "n/%",
                "P/%",
                "人员",
            ],];
        const Data = this.state.Data;
        for (let i = 0; i < 8; i++) {
            let xiaoshi = i + this.props.timeChose * 8;
            const value = Data[xiaoshi]['shuju'];
            data.push(
                [
                    this.state.Time[i],
                    isNaN(value[0]) ? null : value[0],
                    isNaN(value[1]) ? null : value[1],
                    isNaN(value[2]) ? null : value[2],
                    isNaN(value[3]) ? null : value[3],
                    isNaN(value[4]) ? null : value[4],
                    isNaN(value[5]) ? null : value[5],
                    isNaN(value[6]) ? null : value[6],
                    isNaN(value[7]) ? null : value[7],
                    isNaN(value[8]) ? null : value[8],
                    isNaN(value[9]) ? null : value[9],
                    isNaN(value[10]) ? null : value[10],
                    isNaN(value[11]) ? null : value[11],
                    isNaN(value[12]) ? null : value[12],
                    isNaN(value[13]) ? null : value[13],
                    isNaN(value[14]) ? null : value[14],
                    Data[xiaoshi]['name'],
                ],
            )
        }

        //数据的自动处理显示部分
        const XiaoShi = this.props.timeChose * 15;
        const average = this.state.average;
        data.push(
            [
                '平均',
                average[XiaoShi],
                average[1 + XiaoShi],
                average[2 + XiaoShi],
                average[3 + XiaoShi],
                average[4 + XiaoShi],
                average[5 + XiaoShi],
                average[6 + XiaoShi],
                average[7 + XiaoShi],
                average[8 + XiaoShi],
                average[9 + XiaoShi],
                average[10 + XiaoShi],
                average[11 + XiaoShi],
                average[12 + XiaoShi],
                average[13 + XiaoShi],
                average[14 + XiaoShi],
                null,
            ],
            [
                '合格率',
                null, null,
                null, null,
                null, null,
                null, null,
                null, null,
                null, null,
                this.state.passRate[12 + XiaoShi],
                this.state.passRate[13 + XiaoShi],
                this.state.passRate[14 + XiaoShi],
                null,
            ]
        );

        // const initColumn = [{
        //     title: '工号',
        //     dataIndex: 'employeeNo',
        //     key: 'employeeNo',
        //     className: 'text-monospace',
        // }, {
        //     title: '姓名',
        //     dataIndex: 'employeeName',
        //     key: 'employeeName',
        // }, {
        //     title: '部门',
        //     dataIndex: 'org',
        //     key: 'org',
        //     width: 300,
        //     computed: record => record.org.substring(6),
        // }, {
        //     title: 'Code',
        //     dataIndex: 'processShortCode',
        //     key: 'processShortCode',
        //     className: 'text-monospace',
        // }, {
        //     title: '假期类型',
        //     dataIndex: 'leaveTypeLabel',
        //     key: 'leaveTypeLabel',
        // }, {
        //     title: '天数',
        //     dataIndex: 'days',
        //     key: 'days',
        //     className: 'text-monospace text-right',
        // }, {
        //     title: '事由',
        //     dataIndex: 'subject',
        //     key: 'subject',
        //     width: 200,
        // }, {
        //     title: '开始时间',
        //     dataIndex: 'startTime',
        //     key: 'startTime',
        //     className: 'text-monospace',
        // }, {
        //     title: '结束时间',
        //     dataIndex: 'endTime',
        //     key: 'endTime',
        //     className: 'text-monospace',
        // }];
        //
        // const _headers = initColumn
        //     .map((item, i) => Object.assign({}, {
        //         key: item.key,
        //         title: item.title,
        //         position: String.fromCharCode(65 + i) + 1
        //     }))
        //     .reduce((prev, next) => Object.assign({}, prev, {[next.position]: {key: next.key, v: next.title}}), {});
        //
        // // 合并 headers 和 data
        // const output = Object.assign({}, _headers);
        // // 获取所有单元格的位置
        // const outputPos = Object.keys(output);
        // // 计算出范围 ,["A1",..., "H2"]
        // const ref = `${outputPos[0]}:${outputPos[outputPos.length - 1]}`;
        //
        // var data2 = [["id", "name", "value"], [1, "sheetjs", 7262], [2, "js-xlsx", 6969]];
        var worksheet = XLSX.utils.aoa_to_sheet(data);
        // 构建 workbook 对象
        const wb = {
            SheetNames: ['mySheet'],
            Sheets: {
                mySheet: worksheet,
            },
        };

        // 导出 Excel
        XLSX.writeFile(wb, '出磨生料原材料化学分析报告单.xlsx');

        // var data = {
        //     cols: [{ name: "A", key: 0 }, { name: "B", key: 1 }, { name: "C", key: 2 }],
        //     data: [
        //         [ "id",    "name", "value" ],
        //         [    1, "sheetjs",    7262 ],
        //         [    2, "js-xlsx",    6969 ]
        //     ]
        // }
        // var worksheet = XLSX.utils.aoa_to_sheet(data);
        // var new_workbook = XLSX.utils.book_new();
        // XLSX.utils.book_append_sheet(new_workbook, worksheet, "SheetJS");
    }

    render() {

        // 表头
        const columns = [
            {
                title: '时间',
                key: 'time',
                dataIndex: 'time',
            },
            {
                title: '附着水',
                dataIndex: 'FuZhuoShui_list',
                key: 'FuZhuoShui_list',
            },
            {
                title: '不溶物',
                key: 'BuRongWu_list',
                dataIndex: 'BuRongWu_list',
            },
            {
                title: 'LL/%',
                key: 'LL_list',
                dataIndex: 'LL_list',
            },
            {
                title: 'SiO2/%',
                key: 'ErYangHG_list',
                dataIndex: 'ErYangHG_list',
            },
            {
                title: 'Al2O3/%',
                key: 'YangHuaL_list',
                dataIndex: 'YangHuaL_list',
            },
            {
                title: 'Fe2O3/%',
                key: 'YangHuaT_list',
                dataIndex: 'YangHuaT_list',
            },
            {
                title: 'CaO/%',
                key: 'YangHuaG_list',
                dataIndex: 'YangHuaG_list',
            },
            {
                title: 'MgO/%',
                key: 'YangHuaMei_list',
                dataIndex: 'YangHuaMei_list',
            },
            {
                title: 'MnO/%',
                key: 'YangHuaMeng_list',
                dataIndex: 'YangHuaMeng_list',
            },
            {
                title: 'TO/%',
                key: 'TO_list',
                dataIndex: 'TO_list',
            },
            {
                title: 'SO3/%',
                key: 'SanYangHL_list',
                dataIndex: 'SanYangHL_list',
            },
            {
                title: '合计',
                key: 'HeJi',
                dataIndex: 'HeJi',
            },
            {
                title: 'KH/%',
                key: 'KH_list',
                dataIndex: 'KH_list',
            },
            {
                title: 'n/%',
                key: 'n',
                dataIndex: 'n',
            },
            {
                title: 'P/%',
                key: 'P',
                dataIndex: 'P',
            },
            {
                title: '人员',
                key: 'person',
                dataIndex: 'person',
            },
            {
                title: '暂存',
                key: 'btn_save',
                dataIndex: 'btn_save',
            }
        ];

        const data = [];

        // /**限制输入数值位数的函数**/
        // const limitDecimals2 = (value: string | number): string => {
        //     const reg = /^(\-)*(\d+)\.(\d\d).*$/;
        //     if (typeof value === 'string') {
        //         return !isNaN(Number(value)) ? value.replace(reg, '$1$2.$3') : ''
        //     } else if (typeof value === 'number') {
        //         return !isNaN(value) ? String(value).replace(reg, '$1$2.$3') : ''
        //     } else {
        //         return ''
        //     }
        // };
        // const limitDecimals3 = (value: string | number): string => {
        //     const reg = /^(\-)*(\d+)\.(\d\d\d).*$/;
        //     if (typeof value === 'string') {
        //         return !isNaN(Number(value)) ? value.replace(reg, '$1$2.$3') : ''
        //     } else if (typeof value === 'number') {
        //         return !isNaN(value) ? String(value).replace(reg, '$1$2.$3') : ''
        //     } else {
        //         return ''
        //     }
        // };

        //中间八行的数据输入
        const Data = this.state.Data;
        for (let i = 0; i < 8; i++) {
            let xiaoshi = i + this.props.timeChose * 8;
            const value = Data[xiaoshi]['shuju'];
            data.push(
                {
                    time: this.state.Time[i],
                    FuZhuoShui_list: <span><Input
                        style={this.changeStyle(value[0])}
                        defaultValue={''}
                        value={isNaN(value[0]) ? null : value[0]}
                        onBlur={() => this.updataData(this.props.standard)}
                        onChange={event => this.onInputNumberChange2(event.target.value, i, 0)}
                    /></span>,
                    BuRongWu_list: <span><Input
                        style={this.changeStyle(value[1])}
                        defaultValue={''}
                        value={isNaN(value[1]) ? null : value[1]}
                        onBlur={() => this.updataData(this.props.standard)}
                        onChange={event => this.onInputNumberChange2(event.target.value, i, 1)}
                    /></span>,
                    LL_list: <span><Input
                        style={this.changeStyle(value[2])}
                        defaultValue={''}
                        value={isNaN(value[2]) ? null : value[2]}
                        onBlur={() => this.updataData(this.props.standard)}
                        onChange={event => this.onInputNumberChange2(event.target.value, i, 2)}
                    /></span>,
                    ErYangHG_list: <span><Input
                        style={this.changeStyle(value[3])}
                        defaultValue={''}
                        value={isNaN(value[3]) ? null : value[3]}
                        onBlur={() => this.updataData(this.props.standard)}
                        onChange={event => this.onInputNumberChange2(event.target.value, i, 3)}
                    /></span>,
                    YangHuaL_list: <span><Input
                        style={this.changeStyle(value[4])}
                        defaultValue={''}
                        value={isNaN(value[4]) ? null : value[4]}
                        onBlur={() => this.updataData(this.props.standard)}
                        onChange={event => this.onInputNumberChange2(event.target.value, i, 4)}
                    /></span>,
                    YangHuaT_list: <span><Input
                        style={this.changeStyle(value[5])}
                        defaultValue={''}
                        value={isNaN(value[5]) ? null : value[5]}
                        onBlur={() => this.updataData(this.props.standard)}
                        onChange={event => this.onInputNumberChange2(event.target.value, i, 5)}
                    /></span>,
                    YangHuaG_list: <span><Input
                        style={this.changeStyle(value[6])}
                        defaultValue={''}
                        value={isNaN(value[6]) ? null : value[6]}
                        onBlur={() => this.updataData(this.props.standard)}
                        onChange={event => this.onInputNumberChange2(event.target.value, i, 6)}
                    /></span>,
                    YangHuaMei_list: <span><Input
                        style={this.changeStyle(value[7])}
                        defaultValue={''}
                        value={isNaN(value[7]) ? null : value[7]}
                        onBlur={() => this.updataData(this.props.standard)}
                        onChange={event => this.onInputNumberChange2(event.target.value, i, 7)}
                    /></span>,
                    YangHuaMeng_list: <span><Input
                        style={this.changeStyle(value[8])}
                        defaultValue={''}
                        value={isNaN(value[8]) ? null : value[8]}
                        onBlur={() => this.updataData(this.props.standard)}
                        onChange={event => this.onInputNumberChange2(event.target.value, i, 8)}
                    /></span>,
                    TO_list: <span><Input
                        style={this.changeStyle(value[9])}
                        defaultValue={''}
                        value={isNaN(value[9]) ? null : value[9]}
                        onBlur={() => this.updataData(this.props.standard)}
                        onChange={event => this.onInputNumberChange2(event.target.value, i, 9)}
                    /></span>,
                    SanYangHL_list: <span><Input
                        style={this.changeStyle(value[10])}
                        defaultValue={''}
                        value={isNaN(value[10]) ? null : value[10]}
                        onBlur={() => this.updataData(this.props.standard)}
                        onChange={event => this.onInputNumberChange2(event.target.value, i, 10)}
                    /></span>,
                    HeJi: <span><Input
                        style={this.changeStyle(value[11])}
                        defaultValue={''}
                        value={isNaN(value[11]) ? null : value[11]}
                        onBlur={() => this.updataData(this.props.standard)}
                        onChange={event => this.onInputNumberChange2(event.target.value, i, 11)}
                    /></span>,
                    KH_list: <span><Input
                        style={this.changeStyle(value[12])}
                        defaultValue={''}
                        value={isNaN(value[12]) ? null : value[12]}
                        onBlur={() => this.updataData(this.props.standard)}
                        onChange={event => this.onInputNumberChange2(event.target.value, i, 12)}
                    /></span>,
                    n: <span><Input
                        style={this.changeStyle(value[13])}
                        defaultValue={''}
                        value={isNaN(value[13]) ? null : value[13]}
                        onBlur={() => this.updataData(this.props.standard)}
                        onChange={event => this.onInputNumberChange2(event.target.value, i, 13)}
                    /></span>,
                    P: <span><Input
                        style={this.changeStyle(value[14])}
                        defaultValue={''}
                        value={isNaN(value[14]) ? null : value[14]}
                        onBlur={() => this.updataData(this.props.standard)}
                        onChange={event => this.onInputNumberChange2(event.target.value, i, 14)}
                    /></span>,
                    // Remarks_list:<span><Input
                    //     style={{
                    //         width:"60px",
                    //         resize:"none"
                    //     }
                    //     }
                    //     defaultValue={''}
                    //     value={value[15]}
                    //     onChange={event=>this.onInputStringChange(event,i,15)}
                    // /></span>,
                    person: Data[xiaoshi]['name'],
                    btn_save: <Button type='primary' onClick={() => this.postToHome(i)}>暂存</Button>,
                }
            )
        }

        //数据的自动处理显示部分
        const xiaoshi = this.props.timeChose * 15;
        data.push(
            {
                time: '平均',
                FuZhuoShui_list: this.state.average[xiaoshi],
                BuRongWu_list: this.state.average[1 + xiaoshi],
                LL_list: this.state.average[2 + xiaoshi],
                ErYangHG_list: this.state.average[3 + xiaoshi],
                YangHuaL_list: this.state.average[4 + xiaoshi],
                YangHuaT_list: this.state.average[5 + xiaoshi],
                YangHuaG_list: this.state.average[6 + xiaoshi],
                YangHuaMei_list: this.state.average[7 + xiaoshi],
                YangHuaMeng_list: this.state.average[8 + xiaoshi],
                TO_list: this.state.average[9 + xiaoshi],
                SanYangHL_list: this.state.average[10 + xiaoshi],
                HeJi: this.state.average[11 + xiaoshi],
                KH_list: this.state.average[12 + xiaoshi],
                n: this.state.average[13 + xiaoshi],
                P: this.state.average[14 + xiaoshi],

            },
            {
                time: '合格率',
                // FuZhuoShui_list: '--',
                // BuRongWu_list: '--',
                // LL_list: '--',
                // ErYangHG_list: '--',
                // YangHuaL_list: '--',
                // YangHuaT_list: '--',
                // YangHuaG_list: '--',
                // YangHuaMei_list: '--',
                // YangHuaMeng_list: '--',
                // TO_list: '--',
                // SanYangHL_list: '--',
                // HeJi: '--',
                KH_list: this.state.passRate[12 + xiaoshi],
                n: this.state.passRate[13 + xiaoshi],
                P: this.state.passRate[14 + xiaoshi],
            }
        );

        return (
            <div className="upper">
                {/*表格填写*/}
                <Table columns={columns} bordered dataSource={data} pagination={false}
                       rowClassName={this.setClassName}/>
            </div>

        );
    }

}

export default UpperPartOfTheForm;